package cn.edu.flow.test;

import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * 测试流程定义
 */
@Slf4j
@SpringBootTest
public class Part2_ProcessDefinition {

    @Autowired
    private RepositoryService repositoryService;

    /**
     * 查询流程定义
     */
    @Test
    public void getDefinitions(){
        List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();
        for(ProcessDefinition pd : list){
            log.info("------流程定义--------");
            log.info("Name："+pd.getName());
            log.info("Key："+pd.getKey());
            log.info("ResourceName："+pd.getResourceName());
            log.info("DeploymentId："+pd.getDeploymentId());
            log.info("Version："+pd.getVersion());

        }

    }

    /**
     * 删除流程定义
     */
    @Test
    public void delDefinition(){

        String pdID="44b15cfe-ce3e-11ea-92a3-dcfb4875e032";
        repositoryService.deleteDeployment(pdID,true);
        log.info("删除流程定义成功");

    }
}
